﻿using System;
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;

namespace DiffLib.Tests
{
    [TestFixture]
    public class PatienceModificationTests
    {
        [Test]
        public void CorrectPlacementOfDiff()
        {
            const string source1 = "a{ } c{ }";
            const string source2 = "a{ } b{ } c{ }";

            var diff = new Diff<char>(source1.ToCharArray(), source2.ToCharArray()).ToArray();
            CollectionAssert.AreEqual(new[]
            {
                new DiffChange(true, 5, 5),
                new DiffChange(false, 0,  5),
                new DiffChange(true, 4, 4)
            }, diff);
        }

        [Test]
        public void WhitespaceTest()
        {
            const string source1 = "        a b c";
            const string source2 = "            a b c";

            var diff = new Diff<char>(source1.ToCharArray(), source2.ToCharArray()).ToArray();
            CollectionAssert.AreEqual(new[]
            {
                new DiffChange(true, 8, 8),
                new DiffChange(false, 0, 4),
                new DiffChange(true, 5, 5)
            }, diff);
        }
    }
}
